package crivia.eca.script;

import java.util.HashMap;
import java.util.Map;

import crivia.txt.common.Text;

public class ScriptLoader {
	
	private static Map<String , String> StaticScripts = new HashMap<String, String>();
	
	public static String load(String flieName){
		if (! StaticScripts.containsKey(flieName)){
			synchronized (StaticScripts) {
				StaticScripts.put(flieName, Text.get(ScriptLoader.class.getResourceAsStream(flieName)));
			}
		}
		return StaticScripts.get(flieName);
	}
	
	public static String load(String flieName , Class<?> target){
		if (! StaticScripts.containsKey(flieName)){
			synchronized (StaticScripts) {
				StaticScripts.put(flieName, Text.get(target.getResourceAsStream(flieName)));
			}
		}
		return StaticScripts.get(flieName);
	}

}
